package com.car.json;

import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import com.car.util.DocUtil;

public class BitAutoBBSUrlCrawl implements Runnable {
	private BitAutoBBSUrlSpell b;
	private String urlSpell;
	public void start(String urlSpell) {
		String url = "http://car.bitauto.com/" + urlSpell + "/koubei/";
		System.out.println(url);
		Document doc = DocUtil.getDoc(url);
		Elements eles = doc.select("div#car_tag li");
		String[] ss = eles.get(eles.size() - 1).select("a").attr("href").split("/");
		String link = ss.length > 3 ? ss[3] : "";
		b.insertBBSUrl(link, urlSpell);
	}

	@Override
	public void run() {
		this.start(this.urlSpell);
	}

	public BitAutoBBSUrlCrawl(BitAutoBBSUrlSpell b, String urlSpell) {
		super();
		this.b = b;
		this.urlSpell = urlSpell;
	}

}
